package com.my.memcached;


import net.spy.memcached.MemcachedClient;
import net.spy.memcached.internal.OperationFuture;

import java.io.IOException;
import java.net.InetSocketAddress;

public class ConnectMemcached {

    public static void main(String[] args) {

        try {
            MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
            System.out.println("Connect to memcache successfully");
            OperationFuture<Boolean> operation = mcc.set("myName",900, "clock");
            System.out.println(operation.isDone());
            Object obj = mcc.get("myName");
            System.out.println("get result is :" + obj.toString());

        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
